home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan 2
/
Opus 5 - Magellan 2.iso
/
Extras
/
TwinOpus2
/
REXX
/
DOpus
/
CopyFile.rexx
next >
Wrap
OS/2 REXX Batch file
|
1994-10-13
|
4KB
|
162 lines
/*
*
* Copy file(s) with TwinExpres from DOpus.
*
* (c) 1994 by K.P. van Beem (2:280/464.2, patrick.van.beem@aobh.xs4all.nl)
*
* Based on the DOpusLhaARexx package by Geoff Seeley (but you can better
* use GuiArc in stead of DOpus and a script, to deal with archives)
*
*/
DOpusPort = 'DOPUS.1'
if ~show(l,"rexxsupport.library") then
call addlib("rexxsupport.library",0,-30,0)
if showlist('Ports', DOpusPort) = 0 then do
say 'Directory Opus Arexx port not found. Aborting.'
call CleanUp
end
address 'DOPUS.1'
options results
/* setup DOpus window and tell user what's happening */
Busy on
TopText "Copying selected files..."
/* Get the destenation path */
OtherWindow
'Status 6 -1'
GetEntry Result
ToPath = Result
if left(ToPath,1) = '*' then do
ToPath = SubStr(ToPath,2)
DoReread='TRUE'
end
else do
'Status 13 -1'
ToPath = result
if ToPath = '' then do
TopText "No destenation directory selected."
call CleanUp
end
DoReread='FALSE'
end
ToPath=Quote(ToPath)
OtherWindow
/* Get the current path and do file-copy, depending on the */
/* type of path (Twin-path or normal path) */
'Status 6 -1'
GetEntry Result
FilePath = Result
/* Twin-way */
if left(FilePath,1) = '*' then do
FilePath = SubStr(FilePath,2)
GetSelectedAll
SelectedEntries = result
if SelectedEntries = 'RESULT' then do
TopText "No files selected."
call CleanUp
end
NumberOfEntries = words(SelectedEntries)
do EntryNumber = 1 to NumberOfEntries
Index = word(SelectedEntries, EntryNumber)
GetEntry Index+1
Entry = result
File = strip(left(Entry,25))
if right(FilePath,1) = ':' then
File = Quote(FilePath || File)
else
File = Quote(FilePath || '/' || File)
address command 'echo >PPipe: copy' File ToPath 'ALL'
selection = Index||' 0 0'
SelectEntry selection
end
end
/* Normal way */
else do
'Status 13 -1'
FilePath = result
if FilePath = '' then do
TopText "No source directory selected."
call CleanUp
end
'GetSelectedAll "|" -1'
SelectedEntries = result
if SelectedEntries = 'RESULT' then do
TopText "No files selected."
call CleanUp
end
NumberOfEntries = CountWords(SelectedEntries)
do EntryNumber = 1 to NumberOfEntries
File = GetWord(EntryNumber, SelectedEntries)
SelectFile Quote(File)
File = Quote(FilePath || File)
address command 'echo >PPipe: copy' File ToPath 'ALL'
end
end
TopText "Ready"
'DisplayDir -1'
if DoReread='TRUE' then do
otherwindow
address AREXX "Rexx:DOpus/Reread.rexx"
end
call CleanUp
exit
/*---------------------------------------------------------------------------*/
CleanUp: /* Remove any files and exit */
Busy off
exit
return
/*--------------------------------------------------------------------------*/
Quote: procedure /* add quotes to string */
parse arg string
return '"'||string||'"'
/*--------------------------------------------------------------------------*/
GetWord: procedure /* get word from '|' separated string */
parse arg number,words
if(left(words,1) ~= '|') then
words = '|'||words
do i=1 to number
idx = index(words, '|');
words = substr(words, idx+1)
end
end = index(words, '|') - 1
if words = "" then
return ""
ret_str = substr(words, 1, end)
return ret_str
/*--------------------------------------------------------------------------*/
CountWords: procedure /* count words from '|' separated string */
parse arg words
count = 0
idx = index(words, '|')
do while idx ~= 0
count = count + 1
words = substr(words, idx+1)
idx = index(words, '|')
end
return count